<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="./vue.js"></script>
  <script src="./vuex.js"></script>
</head>

<body>
  <div id="app">
    <button @click="increment">+ v +</button>
    <p>{{ this.$store.state.count }}</p>
  </div>

  <script>
    const store = new Vuex.Store({
      state: {
        count: 0
      },
      mutations: {
        increase(state) {
          state.count++;
        }
      }
    })

    const vm = new Vue({
      el: "#app",
      store,
      methods: {
        increment() {
          // 提交mutation里面的事件,每提交一次就是触发一次该事件
          this.$store.commit("increase")
        }
      }
    })
  </script>
</body>

</html>